package kp.rpc.Enum;

import lombok.Getter;

/**
 * 协议消息的类型枚举
 */
@Getter
public enum ProtocolMessageTypeEnum {
    REQUEST(0),
    RESPONSE(1),
    HEART_BEAT(2),
    OTHERS(3);
    private final int key;

    ProtocolMessageTypeEnum(int key) {
        this.key = key;
    }

    public static ProtocolMessageTypeEnum getEnumByKey(int key) {
        ProtocolMessageTypeEnum[] values = ProtocolMessageTypeEnum.values();
        for (ProtocolMessageTypeEnum protocolMessageTypeEnum : values) {
            if (protocolMessageTypeEnum.key == key) {
                return protocolMessageTypeEnum;
            }
        }
        return null;
    }
}
